#pragma once
#include "../ComPropVariant.h"
#include "../MemPtr.h"
#include "SevenZipInterfaces.h"

namespace SevenZip
{

struct CSevenZipArchiveItem
{
	CSevenZipArchiveItem();
	CSevenZipArchiveItem(CComPtr<IInArchive> &);
	CSevenZipArchiveItem(CComPtr<IInArchive> &, UINT32);
	~CSevenZipArchiveItem();

	STDMETHODIMP IsFolder(__out PBOOL) CONST;

	STDMETHODIMP GetName(CStringW &) CONST;
	STDMETHODIMP GetType(CStringW &) CONST;
	STDMETHODIMP GetPath(CStringW &) CONST;
	STDMETHODIMP GetParentPath(CStringW &) CONST;

	STDMETHODIMP GetPropertyValue(PROPID, CComPropVariant &) CONST;

	VOID AddChildItem(__in CSevenZipArchiveItem * Item)
	{
		_ChildItems.Add(Item);
	}

	size_t GetItemCount() CONST
	{
		return _ChildItems.GetCount();
	}

	CSevenZipArchiveItem * GetItem(size_t Index) CONST
	{
		return _ChildItems.GetAt(Index);
	}

	VOID SetIndex(UINT32 NewIndex)
	{
		_Index = NewIndex;
	}

	enum
	{
		ITEMPROP_Path = 3,
		ITEMPROP_Name,
		ITEMPROP_Extension,
		ITEMPROP_IsDirectory,
		ITEMPROP_Size,
		ITEMPROP_PackedSize,
		ITEMPROP_Attributes,
		ITEMPROP_DateCreated,
		ITEMPROP_DateAccessed,
		ITEMPROP_DateModified,
	};

private:

	STDMETHODIMP GetPropertyValue(PROPID, CComMemPtr<WCHAR> &) CONST;

	CAtlArray<CSevenZipArchiveItem *> _ChildItems;
	CComPtr<IInArchive> _Archive;
	UINT32 _Index;

	mutable CStringW _Path;
};

}